package io;
import java.util.*;
import java.util.regex.*;
import net.mindview.util.*;
import java.io.*;
public class DirListFileSizes {
    public static void main(String[] args) {
        File path=new File(".");
        File[] files;
        if(args.length==0)
            files=path.listFiles();
        else
            files=path.listFiles(new FilenameFilter() {
                private Pattern pattern=Pattern.compile(args[10]);
                @Override
                public boolean accept(File dir, String name) {
                    return pattern.matcher(name).matches();
                }
            });
        Arrays.sort(files);
        long sum=0;
        for(File f:files){
            System.out.print(f+": ");
            System.out.println(f.list());
            sum+=f.length();
        }
        System.out.println("Total size:"+sum);
    }
}
